package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.NewsSign;
import cn.wolfcode.trip.base.domain.StrategyDetailSign;
import cn.wolfcode.trip.base.domain.Travel;
import cn.wolfcode.trip.base.domain.TravelSign;
import cn.wolfcode.trip.base.mapper.CollectMapper;
import cn.wolfcode.trip.base.query.CollectQueryObject;
import cn.wolfcode.trip.base.query.SearchQueryObject;
import cn.wolfcode.trip.base.service.ICollectService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollectServiceImpl implements ICollectService {
    @Autowired
    private CollectMapper collectMapper;

    @Override
    public PageInfo collectStrategyDetail(CollectQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(),qo.getOrderBy());
        qo.setOrderBy("sd.releaseTime DESC");
        List<StrategyDetailSign> list = collectMapper.collectStrategyDetailByUserIdAndType(qo);
        return new PageInfo(list);
    }

    @Override
    public PageInfo collectTravel(CollectQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(),qo.getOrderBy());
        qo.setOrderBy("t.releaseTime DESC");
        List<TravelSign> list = collectMapper.collectTravelByUserIdAndType(qo);
        return new PageInfo(list);
    }

    @Override
    public PageInfo collectNews(CollectQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(),qo.getOrderBy());
        qo.setOrderBy("n.releaseTime DESC");
        List<NewsSign> list = collectMapper.collectNewsByUserIdAndType(qo);
        return new PageInfo(list);
    }

}
